namespace PPM.Blog.Repository.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddForeignKey : DbMigration
    {
        public override void Up()
        {
            AddColumn("dbo.T_User", "Phone", c => c.String());
            CreateIndex("dbo.T_Menu", "CreatorId");
            CreateIndex("dbo.T_Menu", "LastModifierId");
            CreateIndex("dbo.T_User", "CreatorId");
            CreateIndex("dbo.T_User", "LastModifierId");
            CreateIndex("dbo.T_Role", "CreatorId");
            CreateIndex("dbo.T_Role", "LastModifierId");
            AddForeignKey("dbo.T_User", "CreatorId", "dbo.T_User", "Id");
            AddForeignKey("dbo.T_User", "LastModifierId", "dbo.T_User", "Id");
            AddForeignKey("dbo.T_Menu", "CreatorId", "dbo.T_User", "Id", cascadeDelete: true);
            AddForeignKey("dbo.T_Menu", "LastModifierId", "dbo.T_User", "Id");
            AddForeignKey("dbo.T_Role", "CreatorId", "dbo.T_User", "Id", cascadeDelete: true);
            AddForeignKey("dbo.T_Role", "LastModifierId", "dbo.T_User", "Id");
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.T_Role", "LastModifierId", "dbo.T_User");
            DropForeignKey("dbo.T_Role", "CreatorId", "dbo.T_User");
            DropForeignKey("dbo.T_Menu", "LastModifierId", "dbo.T_User");
            DropForeignKey("dbo.T_Menu", "CreatorId", "dbo.T_User");
            DropForeignKey("dbo.T_User", "LastModifierId", "dbo.T_User");
            DropForeignKey("dbo.T_User", "CreatorId", "dbo.T_User");
            DropIndex("dbo.T_Role", new[] { "LastModifierId" });
            DropIndex("dbo.T_Role", new[] { "CreatorId" });
            DropIndex("dbo.T_User", new[] { "LastModifierId" });
            DropIndex("dbo.T_User", new[] { "CreatorId" });
            DropIndex("dbo.T_Menu", new[] { "LastModifierId" });
            DropIndex("dbo.T_Menu", new[] { "CreatorId" });
            DropColumn("dbo.T_User", "Phone");
        }
    }
}
